<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>添加团队管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		$(document).ready(function() {
			$("#btnImport").click(function () {
				$.jBox($("#importBox").html(), {
					title: "批量导入团队", buttons: false
				});
			});
		});

        function teamDetails(teamId , teamLogo){
            console.info(teamId);
            $.ajax({
                type: "POST",
                url: "${ctx}/race/raceTeam/teamDetails",
                data: {
                    teamId:teamId
                },
                success: function (Class) {

                    $("#teamDetails").append("<li>" +   "团队名称："+  teamId  + "</li>");
					$("#teamDetails").append("<li>" + "团队Logo:" + " <img style='width: 50px;height: 50px' src= " + teamLogo + " />  </li>");
                    $("#teamDetails").append("<li>" +   "团队成员："+ "</li>");

							for(var  i = 0; i < Class.length; i++ ){
								$("#teamDetails").append("<li type=''>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +   Class[i].name + "</li>");
					        }

                },
                error:function(){
                    console.info("error");
                }
            });
            $.jBox($("#teamDetailsBox").html(), {title:"查看详情", buttons:{"关闭":true}, submit: function(){}});
        }
    </script>
    <script type="text/template" id="teamDetailsBox">
        <div>
            <ul id="teamDetails" style="list-style:none">
            </ul>
        </div>
	</script>
</head>
<body>

<div id="importBox" class="hide">
	<form id="importForm" action="${ctx}/race/raceTeam/import" method="post" enctype="multipart/form-data"
		  class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
		<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>
		<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   确定   "/>
		<a href="${ctx}/race/raceTeam/import/template">点此下载导入模板</a>
	</form>
</div>

	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/race/raceTeam/">竞赛团队列表</a></li>
		<shiro:hasPermission name="race:raceTeam:edit"><li><a href="${ctx}/race/raceTeam/form">添加团队</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="raceTeam" action="${ctx}/race/raceTeam/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>团队名称：</label>
				<form:input path="teamName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li><div style="width: 60px; height: 20px"> </div></li>
			<li> <input id="btnImport" class="btn btn-primary" type="button" value="导入"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>团队名称</th>
				<th>团队成员</th>
				<shiro:hasPermission name="race:raceTeam:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="raceTeam">
			<tr>
				<td><a href="${ctx}/race/raceTeam/form?id=${raceTeam.id}">
					${raceTeam.teamName}
				</a></td>
				    <td>
					<c:forEach items="${raceUsers}" var="raceUser">
						<c:if test="${raceUser.teamId==raceTeam.teamName}">
							 ${raceUser.name}、
						</c:if>
					</c:forEach>
				    </td>
				<shiro:hasPermission name="race:raceTeam:edit"><td>
                    <a href="javascript:teamDetails('${raceTeam.teamName}', '${raceTeam.teamLogo}')" title="详情">详情</a>
    				<a href="${ctx}/race/raceTeam/form?id=${raceTeam.id}">编辑</a>
					<a href="${ctx}/race/raceTeam/delete?id=${raceTeam.id}" onclick="return confirmx('确认要删除该团队吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>